﻿<div ms-controller="JHGLLIST">
    <!-- 添加按钮 -->
    <div class="btn-add">
        <button type="button" class="btn btn-info btn-lg" ms-click="AddViewNOWF('JHGL/JHGL')"><i class="iconfont icon-jiahao ft12 mr5"></i>添加计划</button>

    </div>
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <h5 class="pull-left tr">计划状态：</h5>
            <ul class="tab-type ft14">
                <li ms-click="SelectJHType('')"><span class="active">全部</span></li>
                <li ms-click="SelectJHType('0')"><span>开</span></li>
                <li ms-click="SelectJHType('1')"><span>关</span></li>

            </ul>
        </div>
       
        <!-- 搜索 -->
        <div class="oh">
            <div class="input-group ml15" style="width:295px;">
                <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="输入计划名称或单位名称">
                <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
            </div>
        </div>
    </div>
    <!-- 展开更多选项 -->
    <div class="add-tab ft14 tc mt20" style="display:none;">
        <span>更多筛选<i class="caret"></i></span>
    </div>
    <!-- 表格 -->
    <div class="default-tab ft14 pt20">
        <table class="table table-striped table-responsive table-hover">
            <thead>
                <tr>
                    <th class="tc">
                        <!--<div class="icheckbox_square-blue">
                            <input type="checkbox">
                            <span class="iconfont icon-check ft12"></span>
                        </div>-->
                        序号
                    </th>
                    <th>名称</th>
                    <th>开关状态</th>
                    <th>起始年月</th>
                    <th>截止年月</th>
                    <th>提报时间</th>
                    <th>提报人</th>
                    <th>
                        操作
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr ms-repeat-el="tmpListData">
                    <td class="tc">
                        <!--<div class="icheckbox_square-blue">
                            <input type="checkbox">
                            <span class="iconfont icon-check ft12"></span>
                        </div>-->
                        <span class="ico-radius-r color-greed" ms-if="el.JHStatus!=1"></span>
                        <span class="ico-radius-r color-red" ms-if="el.JHStatus==1"></span>

                        {{$index+1+page.pagecount*(page.pageindex-1)}}
                    </td>
                    <td>{{el.JHTitle}}</td>
                    <td >{{el.JHStatus=='0'?"开":"关"}}</td>
                    <td>{{el.SDate}}</td>
                    <td>{{el.EDate}}</td>
                    <td>{{el.CRDate}}</td>
                    <td>{{el.ShenQingRen}}</td>

                    <td>

                        <!--<a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="计划明细" ms-click="ShowJHData(el)">
                            <i class="iconfont icon-liebiao3 "></i>
                        </a>-->
                   
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="关闭计划" ms-if="el.JHStatus=='0'" ms-click="UPJH(el,$event)" style="margin-left: 10px; color:orangered">
                            <i class="iconfont icon-stop"></i>
                        </a>
                        <a class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="开启计划" ms-if="el.JHStatus=='1'" ms-click="UPJH(el,$event)" style="margin-left: 10px;">
                            <i class="iconfont icon-gjjl"></i>
                        </a>
                        <!--<a class="cz-btn ft18 sc-color tip" data-toggle="tooltip" title="删除计划" ms-click="DELJH(el,$event)" style="margin-left: 10px;">
                            <i class="iconfont icon-shanchu"></i>
                        </a>-->
                    </td>
                </tr>

            </tbody>
            <tfoot>
                <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
            </tfoot>
        </table>
        <div class="ui-datatable-page ft14 pl20">

            <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
            <div class="pull-right" ms-visible="tmpListData.size()!=0">
                <span>共{{model.page.total}}条记录</span>
                <span ms-visible="model.page.total>model.pageNum[0].num">
                    选择每页条数
                    <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                        <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                    </select>
                </span>
            </div>

        </div>
    </div>
</div>

<script>

    var tempindex = avalon.define({
        $id: "JHGLLIST",
        selNum: function (item) {    //选择显示的条数
            model.page.pagecount = item;
            tempindex.GetLIST();
        },
        tmpListData: [],
        curJHType:"",
        SelectJHType: function (status) {
            tempindex.curJHType = status;
            tempindex.GetLIST();

        },
        DELJH: function (item, event) {
            if (event) {
                event.stopPropagation();
            }
            ComFunJS.winconfirm("确认要删除该计划吗", function () {
                $.post("/API/VIEWAPI.ashx?Action=JHGL_DELJH", { P1: item.ID }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempindex.tmpListData.remove(item);
                        ComFunJS.winsuccess("操作成功");
                    }
                })
            }, function () { })
        },
        UPJH: function (item, event) {
            if (event) {
                event.stopPropagation();
            }
            ComFunJS.winconfirm("确认要关闭该计划吗", function () {
                $.post("/API/VIEWAPI.ashx?Action=JHGL_CLOSEJH", { P1: item.ID }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempindex.GetLIST();
                        ComFunJS.winsuccess("操作成功");
                    }
                })
            }, function () { })
        },
        InitWigetData: function () {
            model.search.seartype = "";
            tempindex.GetLIST();
        },
        GetLIST: function () {
            model.page.pageindex = 1;
            tempindex.tmpListData.clear();
            $.getJSON('/API/VIEWAPI.ashx?Action=JHGL_GETLIST_PAGE', { p: 1, P1: model.search.searchcontent,  pagecount: model.page.pagecount, JHStatus: tempindex.curJHType }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempindex.tmpListData = resultData.Result;
                    if (tempindex.tmpListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                    model.page.total = resultData.Result1;
                    laypage({
                        cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                        pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //通过后台拿到的总页数
                        curr: 1, //初始化当前页
                        skin: 'molv',
                        jump: function (e) { //触发分页后的回调
                            if (e.curr != model.page.pageindex) {
                                $.getJSON('/API/VIEWAPI.ashx?Action=JHGL_GETLIST_PAGE', { p: e.curr, P1: model.search.seartype, P2: tempindex.curTSType, pagecount: model.page.pagecount, jystatus: tempindex.curJYType }, function (resultData) {
                                    if (resultData.ErrorMsg == "") {
                                        tempindex.tmpListData = resultData.Result;
                                    }
                                })
                                model.page.pageindex = e.curr;
                            }
                        }
                    });
                }
            })
        }
    })
    //@ sourceURL=JHGLLIST.js;
</script>
